using System;
using Scenario.WorkflowEngine.DataModel;

namespace Scenario.WorkflowEngine.DataModel.WorkflowProcesses
{
	//*********************************************************************
	//
	// XmlTransitions Class
	//
	// The XmlTransitions class represents a collection base of XmlTransition
	// Its imports methods from WAPI.XmlObjectSet like get set and add
	// XmlTransitions Has no fields
	//
	//*********************************************************************

	public class XMLMessages : bOS.XML.Data.XMLObjectSet 
	{
		public const string MAIN_NODE	= "MessageFlows";

		/** FIELDS **/

		/** no fields **/

		/** CONSTRUCTORS **/

		/** CONSTRUCTOR Empty **/
		public XMLMessages()
		{
			this.Init();
		}

		/** CONSTRUCTOR Width xml parsering**/
        public XMLMessages(System.Xml.XmlNode nodeList)
		{
			this.Parse (nodeList);
		}

		/** INSTANCE METHODS **/

		public override void Init()
		{
			this.RemoveAll();
		}

		public override void Parse(System.Xml.XmlNode nodeList)
		{
			this.Init();

			System.Xml.XmlNode node;

			for ( int i=0; i<nodeList.ChildNodes.Count;i++)
			{
				node = nodeList.ChildNodes[i];

				switch ( node.Name) 
				{
                    case XMLMessage.MAIN_NODE:
                        this.Add(new XMLMessage(node));
						break;
				}
			}
		}

		override public bOS.XML.XMLNode GetXMLNode()
		{
            bOS.XML.XMLNode xmlNode = new bOS.XML.XMLNode(XMLMessages.MAIN_NODE);

			for ( int i=0; i<this.Count;i++)
			{
				xmlNode.AddNode ( this[i].GetXMLNode() );

			}

			return xmlNode;
		}
	}
}